/*
 * @Descripttion: 
 * @version: 
 * @Author: 高月飞
 * @Date: 2023-11-17 21:34:02
 * @LastEditors: 高月飞
 * @LastEditTime: 2023-11-22 22:20:42
 */

//网络请求

import { userCustomerPayMessageApi } from "@/services/customer";
import type { ICustomerData } from "@/types/customer";
import { defineStore } from "pinia";


const usePaymesStore = defineStore('paymes', {
    //持久化操作
    //对于登录信息进行一次持久化操作
    persist: {
        storage: window.sessionStorage,
        paths: ['paymesinfo']
    },

    state: () => ({
        paymesinfo: {
            id: 0,
            PlannedPaymentTime: "",
            PaymentMethod: "",
            ReturnRatio: "",
            RefundAmount: "",
            PaymentInformation: "",
            remindertime: "",
            reminderstate: "",
            payPeople: "",
            payDay: "",
            payRemark: "",
        }
    }) as ICustomerData.IRootstore2,

    actions: {
        SETPAYMESINFO(data: ICustomerData.IRootInterface2) {
            this.paymesinfo = data
        },
        SETUSERLOGOUT() {
            this.paymesinfo = {
                id: 0,
                PlannedPaymentTime: "",
                PaymentMethod: "",
                ReturnRatio: "",
                RefundAmount: "",
                PaymentInformation: "",
                remindertime: "",
                reminderstate: "",
                payPeople: "",
                payDay: "",
                payRemark: "",
            }
        },
        async USEPAYMESACTION(id: number) {
            let ret = await userCustomerPayMessageApi(id)
            if (ret.code === 200) {
                this.SETPAYMESINFO(ret.data)
            }
            return ret.data
        }

    },


})
export default usePaymesStore
